<template>
  <div class="dashboard-container">
    <h2 class="page-title">数据概览</h2>
    
    <el-row :gutter="20" class="metric-grid">
      <el-col :xs="24" :sm="12" :md="6" v-for="(item, index) in metrics" :key="index">
        <el-card 
          class="metric-card"
          :style="{ borderLeft: `4px solid ${item.color}` }"
          shadow="hover"
        >
          <div class="metric-content">
            <el-icon class="metric-icon" :color="item.color">
              <component :is="item.icon" />
            </el-icon>
            <div class="metric-info">
              <div class="metric-label">{{ item.label }}</div>
              <div class="metric-value">{{ item.value }}</div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20" class="info-section">
      <el-col :span="24" :md="12">
        <el-card class="user-card">
          <template #header>
            <div class="card-header">
              <el-icon><User /></el-icon>
              <span>用户信息</span>
            </div>
          </template>
          <div class="user-info-grid">
            <div class="info-item">
              <span class="info-label">账户名称</span>
              <span class="info-value">arihu</span>
            </div>
            <div class="info-item">
              <span class="info-label">电子邮箱</span>
              <span class="info-value">huxiaoshou@hotmail.com</span>
            </div>
            <div class="info-item">
              <span class="info-label">注册时间</span>
              <span class="info-value">2025-02-27 14:21:17</span>
            </div>
            <div class="info-item">
              <span class="info-label">注册IP</span>
              <span class="info-value">106.224.156.165</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { FolderOpened, DataAnalysis, InfoFilled, User, Picture } from '@element-plus/icons-vue'

const metrics = [
  {
    icon: Picture,
    label: '图片数量',
    value: '1,024',
    color: '#409EFF'
  },
  {
    icon: FolderOpened,
    label: '可用存储',
    value: '99.97 MB',
    color: '#67C23A'
  },
  {
    icon: DataAnalysis,
    label: '使用存储',
    value: '35.58 KB',
    color: '#E6A23C'
  },
  {
    icon: InfoFilled,
    label: '总存储空间',
    value: '100.00 MB',
    color: '#909399'
  }
]
</script>

<style scoped>
.dashboard-container {
  padding: 20px;
}

.page-title {
  color: #303133;
  margin-bottom: 24px;
  font-weight: 600;
  font-size: 20px;
}

.metric-grid {
  margin-bottom: 24px;
}

.metric-card {
  margin-bottom: 16px;
  transition: transform 0.3s;
  
  &:hover {
    transform: translateY(-3px);
  }
}

.metric-content {
  display: flex;
  align-items: center;
  padding: 12px 0;
}

.metric-icon {
  font-size: 32px;
  margin-right: 16px;
  padding: 8px;
  background: rgba(64, 158, 255, 0.1);
  border-radius: 8px;
}

.metric-info {
  flex: 1;
}

.metric-label {
  color: #606266;
  font-size: 14px;
  margin-bottom: 8px;
}

.metric-value {
  color: #303133;
  font-size: 20px;
  font-weight: 600;
}

.user-card {
  border-top: 2px solid #409EFF;
  
  :deep(.el-card__header) {
    background: #f5f7fa;
    padding: 16px 20px;
  }
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #303133;
  
  .el-icon {
    font-size: 18px;
  }
}

.user-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 12px 0;
}

.info-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
}

.info-label {
  color: #909399;
  font-size: 12px;
  margin-bottom: 4px;
}

.info-value {
  color: #606266;
  font-size: 14px;
  font-weight: 500;
  word-break: break-word;
}

@media (max-width: 768px) {
  .metric-card {
    margin-bottom: 12px;
  }
  
  .metric-icon {
    font-size: 28px;
    padding: 6px;
  }
  
  .metric-value {
    font-size: 18px;
  }
  
  .user-info-grid {
    grid-template-columns: 1fr;
  }
}
</style>